home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-04
/
zbpc_460.zip
/
UTILITY.EXE
/
BCD2BIN.INS
< prev
next >
Wrap
Text File
|
1991-06-08
|
913b
|
27 lines
:'optional dim statement to reduce string size requirements
DIM 6R1$,64R2$,1R3$
LONGFN BCD2BIN# (R$) :'Pass BCD varible in a STRING...
:'BCD data format :'...and it will be converted to binary floating point
:'to BINARY format :'IE. Pass in BCD variable in a string 'READ#3,x$;8'
:' ...instead of 'READ#3,x# '
R2$="" :' and then do 'x#=FN BCD2BIN#(x$)
R1$=LEFT$(R$,1):R1%=ASC(R1$)
IF R1%>127 THEN R2$="-"
R1%=R1% AND 127
FOR R2%= 2 TO LEN(R$)
R1$=MID$(R$,R2%,1):R1$=RIGHT$(HEX$(ASC(R1$)),2)
LONGIF R2%=2
:R3$=LEFT$(R1$,1):R1$=RIGHT$(R1$,1)
:R2$=R2$+R3$+"."+R1$
XELSE :R2$=R2$+R1$
ENDIF
NEXT
R2$=R2$+"E":IF R1%>64 THEN R1%=-(128-R1%)
:R1$=STR$(R1%)
:IFASC(R1$)=32 THEN MID$(R1$,1,1)="+"
R2$=R2$+R1$
ENDFN=VAL(R2$)